package com.longcai.piaojia.activity;

import android.Manifest;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.longcai.piaojia.R;
import com.longcai.piaojia.util.UtilPermission;
import com.umeng.analytics.MobclickAgent;
import com.umeng.analytics.game.UMGameAgent;
import com.zcx.helper.activity.AppV4Activity;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by Administrator on 2016/3/14.
 */
public class BaseActivity extends AppV4Activity {

    public void setBackTrue() {

        try {

            findViewById(R.id.title_back_rl).setVisibility(View.VISIBLE);
            findViewById(R.id.title_back_rl).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    public void setTitleName(String name) {

        try {

            findViewById(R.id.title_name_ll).setVisibility(View.VISIBLE);
            if (name.length() > 10) {

                name = name.substring(0, 10) + "...";

            }
            ((TextView) findViewById(R.id.title_name_tv)).setText(name);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    public void setRightName(String name, int colorId, View.OnClickListener onClickListener) {

        try {

            findViewById(R.id.title_right_ll).setVisibility(View.VISIBLE);
            findViewById(R.id.title_right_name).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.title_right_name)).setText(name);
            ((TextView) findViewById(R.id.title_right_name)).setTextColor(ContextCompat.getColor(getApplicationContext(), colorId));
            findViewById(R.id.title_right_ll).setOnClickListener(onClickListener);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    public void setRightImage(View.OnClickListener onClickListener) {

        try {


            findViewById(R.id.title_right_ll).setVisibility(View.VISIBLE);
            findViewById(R.id.title_share_ll).setVisibility(View.VISIBLE);
            findViewById(R.id.title_collect_ll).setVisibility(View.VISIBLE);
            findViewById(R.id.title_share_ll).setOnClickListener(onClickListener);
            findViewById(R.id.title_collect_ll).setOnClickListener(onClickListener);


        } catch (Exception e) {

            e.printStackTrace();

        }

    }

    public void setLatestRightImage(View.OnClickListener onClickListener) {

        try {


            findViewById(R.id.title_latest_right_ll).setVisibility(View.VISIBLE);

            findViewById(R.id.title_latest_right_ll).setOnClickListener(onClickListener);


        } catch (Exception e) {

            e.printStackTrace();

        }

    }
    @Override
    protected void onResume() {
        super.onResume();

        JPushInterface.onResume(this);

        // 集成基本统计分析,初始化 Session
        MobclickAgent.onResume(this);

    }

    @Override
    protected void onPause() {
        super.onPause();

        JPushInterface.onPause(this);

        // //集成基本统计分析, 结束 Session
        MobclickAgent.onPause(this);

    }

}
